from pyson.gen import PysonObject, struct, boolean
from pyduct.handlers import CookieFragmentBuilder, MessageFragment

class MementoInfoForField(PysonObject):
    isParameter = boolean()

class MementoInfoForFieldHolder(PysonObject):
    MementoInfoForField = struct(MementoInfoForField)

class MementoInfoForFieldBuilder(CookieFragmentBuilder):

    def getCookieMessageFragmentClass(self, cookieGateway, property):
        class Fragment(MementoInfoForFieldHolder, MessageFragment):
            def __init__(self):
                super(Fragment, self).__init__()
                self.MementoInfoForField.isParameter = cookieGateway.isMementoParameter(property.name())

        return Fragment

def getBuilders():
    return (MementoInfoForFieldBuilder,)